<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('客户列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse" style="display: none;">
                <form id="formId">
                	
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>客户名称：</p>
                                <input type="text" name="customerName"/>
                            </li>
                            <li>
                                <p>客户简称：</p>
                                <input type="text" name="nameShort"/>
                            </li>
                            <li>
                                <p>公司座机：</p>
                                <input type="text" name="telephone"/>
                            </li>
                            <li>
                                <p>公司手机：</p>
                                <input type="text" name="mobile"/>
                            </li>
                            <li>
                                <p>公司邮箱：</p>
                                <input type="text" name="email"/>
                            </li>
                            <li>
                                <p>客户地址：</p>
                                <input type="text" name="address"/>
                            </li>
                            <li>
                                <p>所属行业：</p>
                                <select name="industry" th:with="type=${@dict.getType('industry')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>客户状态：</p>
                                <select name="customerStatus" th:with="type=${@dict.getType('crm_customer_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>客户来源：</p>
                                <select name="customerSource" th:with="type=${@dict.getType('crm_customer_source')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>客户等级：</p>
                                <select name="customerDegree" th:with="type=${@dict.getType('crm_customer_degree')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>客户优先级：</p>
                                <select name="customerPriority" th:with="type=${@dict.getType('crm_customer_priority')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>客户信誉度：</p>
                                <select name="customerCredit" th:with="type=${@dict.getType('crm_customer_credit')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>客户成熟度：</label>
                                <select name="customerMaturity" th:with="type=${@dict.getType('crm_customer_maturity')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                             <li>
                                <label>客户类别：</label>
                                <select name="customerCategory" th:with="type=${@dict.getType('crm_customer_category')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li class="select-time">
									<label>创建时间： </label>
									<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
									<span>-</span>
									<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
								</li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="crm:customer:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="crm:customer:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="crm:customer:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                 <div class="btn-group"  shiro:hasPermission="crm:customer:share">
                 	<button data-toggle="dropdown" class="btn  btn-sm btn-primary dropdown-toggle  multiple disabled "><i class="fa fa-group"></i>&nbsp;共享<span class="caret"></span></button>
                    	<ul class="dropdown-menu">
                        	<li><a href="javascript:share(1);">设置为共享</a></li>
                            <li><a href="javascript:share(0);" class="font-bold">取消共享</a></li>
                       	</ul>
                 </div>
                 <div class="btn-group"  shiro:hasPermission="crm:customer:transfer">
                 	<button data-toggle="dropdown" class="btn  btn-sm btn-success dropdown-toggle  multiple disabled "><i class="fa fa-exchange"></i>&nbsp;转交<span class="caret"></span></button>
                    	<ul class="dropdown-menu">
                        	<li><a href="javascript:transferPerson();">转交给指定人员</a></li>
                            <li><a href="javascript:transferPublic();">转为公共客户</a></li>
                       	</ul>
                 </div>
                 <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="crm:customer:import">
					<i class="fa fa-upload"></i> 导入
				</a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="crm:customer:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('crm:customer:edit')}]];
        var removeFlag = [[${@permission.hasPermi('crm:customer:remove')}]];
        var customerTypeDatas = [[${@dict.getType('crm_customer_type')}]];
        var industryDatas = [[${@dict.getType('industry')}]];
        var customerStatusDatas = [[${@dict.getType('crm_customer_status')}]];
        var customerSourceDatas = [[${@dict.getType('crm_customer_source')}]];
        var customerDegreeDatas = [[${@dict.getType('crm_customer_degree')}]];
        var customerPriorityDatas = [[${@dict.getType('crm_customer_priority')}]];
        var customerCreditDatas = [[${@dict.getType('crm_customer_credit')}]];
        var customerTypeDatas = [[${@dict.getType('crm_customer_type')}]];
        var customerMaturityDatas = [[${@dict.getType('crm_customer_maturity')}]];
        var customerCategoryDatas = [[${@dict.getType('crm_customer_category')}]];
        var prefix = ctx + "crm/customer";

        $(function() {
            var options = {
                url: prefix + "/listMy",
                detailUrl: prefix + "/detail/{id}",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                importUrl: prefix + "/importData",
                importTemplateUrl: prefix + "/importTemplate",
		        sortName: "createTime",
		        sortOrder: "desc",
                modalName: "客户",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'customerId', 
                    title : '客户ID',
                    visible: false,
		            sortable: true
                },
                {
                    field : 'customerName', 
                    title : '客户名称',
		            formatter: function(value, row, index) {
		            	if(row.isShare=="1"){
		            		return '<i class="fa fa-group green" title="共享客户"></i><a style="color:blue;" href="javascript:void(0)" title="查看详情" onclick="detail(\'' +row.customerId + '\')">'+value+'</a> ';
		            	}
		            	else if(row.belongTo==""||row.belongTo==null){ 
		            		return '<span style="color:red;" title="这是一个公客">[公客]</span><a style="color:blue;" href="javascript:void(0)" title="查看详情" onclick="detail(\'' +row.customerId + '\')">'+value+'</a> ';
		            	}
		            	else{
		            		return '<a style="color:blue;" href="javascript:void(0)" title="查看详情" onclick="detail(\'' +row.customerId + '\')">'+value+'</a> ';
		            	} 
	                },
		            sortable: true
                },
                {
                    field : 'nameShort', 
                    title : '客户简称',
                    visible: false,
		            sortable: true
                },
                {
                    field : 'customerType', 
                    title : '客户类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(customerTypeDatas, value);
                    },
		            sortable: true
                },
                {
                    field : 'telephone', 
                    title : '公司座机',
                    visible: false,
		            sortable: true
                },
                {
                    field : 'mobile', 
                    title : '公司手机',
                    visible: false,
		            sortable: true
                },
                {
                    field : 'email', 
                    title : '公司邮箱',
                    visible: false,
		            sortable: true
                },
                {
                    field : 'industry', 
                    title : '所属行业',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(industryDatas, value);
                    },
		            sortable: true
                },
                {
                    field : 'customerStatus', 
                    title : '客户状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(customerStatusDatas, value);
                    },
		            sortable: true
                },
                {
                    field : 'customerSource', 
                    title : '客户来源',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(customerSourceDatas, value);
                    },
		            sortable: true
                },
                {
                    field : 'customerDegree', 
                    title : '客户等级',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(customerDegreeDatas, value);
                    },
		            sortable: true
                },
                {
                    field : 'customerPriority', 
                    title : '客户优先级',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(customerPriorityDatas, value);
                    },
		            sortable: true
                },
                {
                    field : 'customerCredit', 
                    title : '客户信誉度',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(customerCreditDatas, value);
                    },
		            sortable: true
                },
                {
                    field : 'customerMaturity', 
                    title : '客户成熟度',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(customerMaturityDatas, value);
                    },
		            sortable: true
                },
                {
                    field : 'customerCategory', 
                    title : '客户类别',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(customerCategoryDatas, value);
                    },
		            sortable: true
                },
                {
                    field : 'getDate', 
                    title : '客户获取时间',
                    visible: false,
		            sortable: true
                },
                {
                    field : 'sourceBelongTo', 
                    title : '原负责人',
                    visible: false,
		            sortable: true
                },
                {
                    field : 'belongTo', 
                    title : '负责人',
		            sortable: true,
		            formatter: function(value, row, index) {
		            	if(row.belongTo==""||row.belongTo==null){
		            		return '<div style="color:red;">[公客]</div>'; 
		            	}else{
		            		return value;
		            	}
	                }
                },
                {
                    field : 'trasferDate', 
                    title : '转交时间',
                    visible: false,
		            sortable: true
                },
                {
                    field : 'trasferTo', 
                    title : '转交人',
                    visible: false,
		            sortable: true
                },
                {
                    field : 'annualIncome', 
                    title : '年收入',
                    visible: false,
		            sortable: true
                },
                {
                    field : 'createBy', 
                    title : '录入人',
		            sortable: true,
                    visible: false
                },
                {
                    field : 'createTime', 
                    title : '录入时间',
		            sortable: true,
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        //actions.push('<a class="btn btn-info btn-xs ' + '" href="javascript:void(0)" onclick="detail(\'' +row.customerId + '\')"><i class="fa fa-search"></i>详细</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.customerId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.customerId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
    </script>
    <script src="../static/crm/customer.js" th:src="@{/crm/customer.js}"></script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
<form enctype="multipart/form-data" class="mt20 mb10">
	<div class="col-xs-offset-1">
		<input type="file" id="file" name="file"/>
		<div class="mt10 pt5">
			<input type="checkbox" id="updateSupport" name="updateSupport" title="如果公司名称已经存在，更新这条数据。"> 是否更新已经存在的客户数据
			 &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
		</div>
		<font color="red" class="pull-left mt10">
			提示：仅允许导入“xls”或“xlsx”格式文件！
		</font>
	</div>
</form>
</script>
</html>